package Controller.Singer;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import Bean.SboardBean;
import Dao.SingerDao;

public class singerBoardInsertController implements Controller{
	private SingerDao dao;
	
	public void setDao(SingerDao dao) {
		this.dao = dao;
	}

	@Override
	public ModelAndView handleRequest(HttpServletRequest req,
			HttpServletResponse arg1) throws Exception {
		Integer s_no = Integer.parseInt(req.getParameter("s_no"));
		String title = req.getParameter("title");
		String context = req.getParameter("context");
		String id = req.getParameter("m_id");
		System.out.println("게시판글 쓰기로 넘어온 시퀀스 값 : "+s_no);
		System.out.println("게시판글 쓰기로 넘어온 제목 : "+title);
		System.out.println("게시판글 쓰기로 넘어온 내용 : "+context);
		System.out.println("게시판글 쓰기로 넘어온 아이디 : "+id);
		
		SboardBean sb = new SboardBean();
		
		sb.setSb_context(context);
		sb.setSb_title(title);
		sb.setSb_s_no(s_no);
		sb.setSb_m_id(id);
		dao.sboardInsert(sb);
		System.out.println("게시판 글 작성 성공!!");
		ModelAndView mav = new ModelAndView();
		mav.setViewName("redirect:/singerBoard.singer?page="+s_no+"&sb_s_no="+s_no);
		return mav;
	}
}
